package com.netty.bfport.http.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.netty.bfport.http.domain.dto.UserLoginDTO;
import com.netty.bfport.http.mapper.UserMapper;
import com.netty.bfport.http.service.UserMsgService;
import com.netty.bfport.http.service.UserService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author: zhaoyang05
 * @Data: 2022/3/30 17:18
 * @Description
 */
@Service
public class UserMsgServiceImpl implements UserMsgService {

    @Resource
    UserMapper userMapper;

    @Override
    public int updateUserInfo(UserLoginDTO userLoginDTO, String userId) {
        UserLoginDTO userDO = new UserLoginDTO();
        BeanUtils.copyProperties(userLoginDTO,userDO);
        userDO.setId(userId);
        return userMapper.updateUserInfo(userDO);
    }

    @Override
    public UserLoginDTO findUserInfo(String userId) {
        UserLoginDTO userDO = userMapper.findUserDO(userId);
        if (userDO==null)return null;
        UserLoginDTO userLoginDTO = new UserLoginDTO();
        BeanUtils.copyProperties(userDO,userLoginDTO);
        return userLoginDTO;
    }

}
